var cont = 0;
function slide(){
	$('.li-px1').on("click",function(){
        $('.slide').addClass('slide2');
        $('.slide').removeClass('slide1');
        $('.li-px1-sp1').addClass('cl-blue');
        $('.li-px1-sp2').removeClass('cl-blue');
        $('.g-jyzk-div-dis').css('display','block');
        $('.displaynone').css('display','none');
        moren();
	});
	$('.li-px2').on("click",function(){
        $('.slide').addClass('slide1');
        $('.slide').removeClass('slide2');
        $('.li-px1-sp1').removeClass('cl-blue');
        $('.li-px1-sp2').addClass('cl-blue');
        $('.g-jyzk-div-dis').css('display','none');
        $('.displaynone').css('display','block');
        paixu1();
	});
}
function paixu1(){
	    cont++;
		ul = $(".g-ul-dplb");
	    var lis = [];
	    lis = $(".li-dplb");
	    ux = [];
	    mr = [];
	    //循环提取时间，并调用排序方法进行排序
	    for (var i=0; i<lis.length; i++){
	        var tmp = {};
	        tmp.dom = lis.eq(i);
	        mr.push(tmp);
	        tmp.date = new Date(lis.eq(i).find(".data").eq(0).html().replace(/-/g,'/'));
	        ux.push(tmp);
	    }
	    //数组排序，支持年的比较
	    ux.sort(function(a,b){

	       var myDate = new Date();
	       var year = myDate.getYear();
	       if(a.date.getYear < year && b.date.getYear == year){
	          return true;
	       }
	       	 if(cont%2==0){
	       	 	$('.li-px2>i').css('background','url(../static/images/managementshop_time1_07.png)');
	       	 	return b.date - a.date;
	       	 }else{
	       	 	$('.li-px2>i').css('background','url(../static/images/managementshop_time2_07.png)');
	       	 	return a.date - b.date;
	       	 }	 
	    });
	    //移除原先顺序错乱的li内容
	    $('.g-ul-dplb>li').remove();
	    //重新填写排序好的内容
	    for (var i=0; i<ux.length; i++){
	       ul.append(ux[i].dom);
	    }
}
function moren(){
	for (var i=0; i<mr.length; i++){
	       ul.append(mr[i].dom);
	  }
	cont--;
}
//点击切换退款列表状态
function slide2(index,txtwidth,txtoffetleft,this1){
	$('.msui_menu-baseline').css({
		"width":+txtwidth+"px",
		'left':+txtoffetleft+"px",
		'transition':'.2s'
	});

	$('.msui_menu-li').on('click',function(){
		var liwidth = $(this)[0].offsetWidth;
		var lioffetleft = $(this).offset().left;
		$('.slide_div').css({
		"width":+liwidth+"px",
		'left':+lioffetleft+"px"
		});
	});
	for(var i = 0;i < 4;i++){
		$('.msui_menu-item').css('color','#999999');
	}
		$(this1).css('color','#3cb1ff');
}


$(function(){
	slide();
	// $('.js-menu>li').on('click',function(){
	// 	var index = $(this).index();
	// 	var this1 = $(this);
	// 	var txtwidth = $(this).width();
	// 	console.log(txtwidth);
	// 	var txtoffetleft = txtwidth * index;
	// 	console.log(txtoffetleft);
	// 	slide2(index,txtwidth,txtoffetleft,this1);
	// });
});
